import { axios } from '@/utils/request'

/**
 * 查询参数列表
 * @param query
 * @returns {*}
 */
export function pageConfig(query) {
  return axios({
    url: '/system/config/page',
    method: 'get',
    params: query
  })
}

/**
 * 查询参数详细
 * @param configId
 * @returns {*}
 */
export function getConfig(configId) {
  return axios({
    url: '/system/config/' + configId,
    method: 'get'
  })
}

/**
 * 根据参数键名查询参数值
 * @param configKey
 * @returns {*}
 */
export function getConfigKey(configKey) {
  return axios({
    url: '/system/config/configKey/' + configKey,
    method: 'get'
  })
}

/**
 * 新增参数配置
 * @param data
 * @returns {*}
 */
export function addConfig(data) {
  return axios({
    url: '/system/config',
    method: 'post',
    data: data
  })
}

/**
 * 修改参数配置
 * @param data
 * @returns {*}
 */
export function updateConfig(data) {
  return axios({
    url: '/system/config',
    method: 'put',
    data: data
  })
}

/**
 * 修改参数配置
 * @param key
 * @param value
 * @returns {*}
 */
export function updateConfigByKey(key, value) {
  return axios({
    url: '/system/config/updateByKey',
    method: 'put',
    data: {
      configKey: key,
      configValue: value
    }
  })
}

/**
 * 删除参数配置
 * @param configId
 * @returns {*}
 */
export function delConfig(configId) {
  return axios({
    url: '/system/config/' + configId,
    method: 'delete'
  })
}

/**
 * 刷新参数缓存
 * @returns {*}
 */
export function refreshCache() {
  return axios({
    url: '/system/config/refreshCache',
    method: 'delete'
  })
}

